package com.xysoft.admin.web;

import java.io.IOException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xysoft.admin.service.IConfigService;

@Controller
@RequestMapping(value = "/admin/config.jspx")
public class ConfigController extends BaseController {
	private IConfigService configService;
	
	@RequestMapping(params = "index")
	public String get(HttpServletResponse response, HttpServletRequest request, 
			HttpSession session) throws IOException {
		String res = this.configService.get();
		response.getWriter().print(res);
		return null;
	}
	
	@RequestMapping(params = "indexOFedit")
	@ResponseBody
	public Map<String,? extends Object> config(HttpServletResponse response, HttpServletRequest request, 
			HttpSession session) throws IOException {
		return this.configService.edit(request);
	}

	@Autowired
	public void setConfigService(IConfigService configService) {
		this.configService = configService;
	}
}
